package com.example.demo.concurrent.Singleton;
/**
 * 静态内部类实现单例模式
 */
public class Singleton5 {
    private Singleton5() {
        System.out.println("Singleton5()");
    }
    /**
     * 静态内部类是只有用到它的时候才会 加载,链接,初始化....
     */
     private static class Holder{
         static Singleton5 INSTANCE = new Singleton5();
     }

     public static Singleton5 getInstance() {
         return Holder.INSTANCE;
     }

     public static void method() {
         System.out.println("method()");
     }
}